import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RuleRelationVO, RuleRelationForm, RuleRelationQuery } from '@/api/shopping/product/ruleRelation/types';

/**
 * 查询规格和商家服务类型列表
 * @param query
 * @returns {*}
 */

export const listRuleRelation = (query?: RuleRelationQuery): AxiosPromise<RuleRelationVO[]> => {
  return request({
    url: '/shopping/product/rule/relation/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询规格和商家服务类型详细
 * @param id
 */
export const getRuleRelation = (id: string | number): AxiosPromise<RuleRelationVO> => {
  return request({
    url: '/shopping/product/rule/relation/' + id,
    method: 'get'
  });
};

/**
 * 新增规格和商家服务类型
 * @param data
 */
export const addRuleRelation = (data: RuleRelationForm) => {
  return request({
    url: '/shopping/product/rule/relation',
    method: 'post',
    data: data
  });
};

/**
 * 修改规格和商家服务类型
 * @param data
 */
export const updateRuleRelation = (data: RuleRelationForm) => {
  return request({
    url: '/shopping/product/rule/relation',
    method: 'put',
    data: data
  });
};

// 查询商品规格关联关系列表
export const getTransferData = (query) => {
  return request({
    url: '/shopping/product/rule/relation/getTransferData',
    method: 'get',
    params: query
  });
};

/**
 * 删除规格和商家服务类型
 * @param id
 */
export const delRuleRelation = (id: string | number | Array<string | number>) => {
  return request({
    url: '/shopping/product/rule/relation/' + id,
    method: 'delete'
  });
};


// 删除商品规格关联关系
export function removeByRuleId(data) {
  return request({
    url: '/shopping/product/rule/relation/removeByRuleId',
    method: 'delete',
    data: data
  })
}
